package com.mdxx.xczd.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.mdxx.xczd.R;
import com.mdxx.xczd.bean.IceNums;
import java.util.List;

/**
 * Created by MD-02 on 2017/2/22.
 */

public class PhoneAdapter extends BaseAdapter{

    private Context context;
    private List<IceNums> data;


    public PhoneAdapter(Context context, List<IceNums> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if(convertView == null){
            viewHolder = new ViewHolder();
            convertView = LayoutInflater.from(context).inflate(R.layout.list_phone_item,parent,false);
            viewHolder.name = (TextView)convertView.findViewById(R.id.tv_phone_name);
            viewHolder.num = (TextView)convertView.findViewById(R.id.tv_phone_num);
            convertView.setTag(viewHolder);
        }else{
            viewHolder =  (ViewHolder)convertView.getTag();
        }
        viewHolder.name.setText(data.get(position).getUserName());
        viewHolder.num.setText(data.get(position).getPhoneNum());
        return convertView;
    }

    class ViewHolder{
        TextView name;
        TextView num;
    }
}
